package com.denlaku.longan.controller;

import com.denlaku.longan.http.Return;
import com.denlaku.longan.qo.DashboardQuery;
import com.denlaku.longan.qo.RefreshQuery;
import com.denlaku.longan.vo.ComponentData;
import com.denlaku.longan.vo.Dashboard;
import com.denlaku.longan.vo.PageBy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * @author tianx
 */
@RequestMapping("/api/dashboard-view")
public interface DashboardViewController {
    /**
     * 根据ID获取仪表板
     *
     * @param id 仪表板ID
     * @return 仪表板
     */
    @GetMapping("/get")
    Return<Dashboard> get(@RequestParam("id") Long id);

    /**
     * 获取去当前用户的仪表板列表
     *
     * @param dashboard 查询参数
     * @param pageBy 分页参数
     * @return 仪表板列表
     */
    @PostMapping("/my-list")
    Return<List<Dashboard>> myList(@RequestBody DashboardQuery dashboard, PageBy pageBy);

    /**
     * 刷新仪表板数据
     *
     * @param queries 查询参数
     * @param debug 是否debug
     * @return 仪表板数据
     */
    @PostMapping("/refreshes")
    Return<List<ComponentData>> refreshes(@RequestBody List<RefreshQuery> queries,
            @RequestParam(defaultValue = "false") boolean debug);

    /**
     * 根据关键词搜索仪表板
     *
     * @param keyword 词搜索关键
     * @return 仪表板
     */
    @GetMapping("/search")
    Return<List<Map<String, String>>> search(@RequestParam("keyword") String keyword);

}
